package com.szpx.service.impl;

import com.szpx.entity.News;
import com.szpx.mapper.NewsMapper;
import com.szpx.service.NewsService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;


@Service
@RequiredArgsConstructor
public class NewsServiceImpl implements NewsService {

    private final NewsMapper newsMapper;



    @Override
    public News createNews(News news) {
        newsMapper.insertSelective(news);
        return news;
    }

    @Override
    public News updateNews(News news) {
        newsMapper.updateByPrimaryKeySelective(news);
        return news;
    }

    @Override
    public boolean deleteNewsById(Integer id) {
        return newsMapper.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public News getNewsById(Integer id) {
        return newsMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<News> getAllNews(News news) {
        return newsMapper.getListByCon( news);
    }



}
